package member_coupon

import (
	// "bp/cache"
	sqlc "bp/db/sqlc"
	// "bp/internal/util"
	"context"
)

type ListAvailableMemberCouponsByForDoTrialParam struct {
	MemberID int64
	BrandID  int64
	OwnerID  int64
	UseScene string
}

// ListAvailableMemberCouponsByForDoTrial 列出可用的试算会员优惠券
func (s *MemberCouponEntityServiceImp) ListAvailableMemberCouponsByForDoTrial(ctx context.Context, q *sqlc.Queries, ptr *ListAvailableMemberCouponsByForDoTrialParam) (memberCouponPtrs []*sqlc.MemberCoupon, err error) {
	// slog := util.NewContextLogger(ctx, s.slog)
	memberCoupons, err := q.ListAvailableMemberCouponsByBrandIDOwnerIDIssuerAndUseScene(ctx, sqlc.ListAvailableMemberCouponsByBrandIDOwnerIDIssuerAndUseSceneParams{
		BrandID:  ptr.BrandID,
		OwnerID:  ptr.OwnerID,
		MemberID: ptr.MemberID,
		UseScene: ptr.UseScene,
	})
	if err != nil {
		return
	}
	memberCouponPtrs = s.MapMemberCouponEntityToPtr(memberCoupons)
	return
}

type ListAvailableMemberCouponsBySnsForDoTrialParam struct {
	MemberID int64
	BrandID  int64
	OwnerID  int64
	Sns      []string
}

// ListAvailableMemberCouponsBySns 根据优惠券序列号列出可用的试算会员优惠券
func (s *MemberCouponEntityServiceImp) ListAvailableMemberCouponsBySnsForDoTrial(ctx context.Context, q *sqlc.Queries, ptr *ListAvailableMemberCouponsBySnsForDoTrialParam) (memberCouponPtrs []*sqlc.MemberCoupon, err error) {
	// slog := util.NewContextLogger(ctx, s.slog)
	memberCoupons, err := q.ListAvailableMemberCouponsBySns(ctx, sqlc.ListAvailableMemberCouponsBySnsParams{
		BrandID:  ptr.BrandID,
		OwnerID:  ptr.OwnerID,
		MemberID: ptr.MemberID,
		Sns:      ptr.Sns,
	})
	if err != nil {
		return
	}
	memberCouponPtrs = s.MapMemberCouponEntityToPtr(memberCoupons)
	return
}
